from bs4 import BeautifulSoup
# 获取概念资金，并清洗数据
with open('D:\\workspace\\python_all\\zz_download_file\\gnzj\\2024-07-20_3.html', 'r', encoding='gbk') as f:
    soup = BeautifulSoup(f.read(), 'html.parser')
    table = soup.find("table")
    # print(table)

    all_tr = table.find_all('tr')
    res_tr = []
    for tr in all_tr:
        all_td = tr.find_all('td')
        res_td = []
        for td in all_td:
            res_td.append(td.get_text())
            # print(td.get_text())
        res_tr.append(res_td)
    res_tr.pop(0)
    print(res_tr)
    # print(all_tr[0].find_all('th')[0].get_text())
    # ----------手动的方式

    # htmlText = f.read()
    # # print(htmlText.split(htmlText.partition(('<table class="m-table J-ajax-table">')))
    # index2 = htmlText.partition('<table class="m-table J-ajax-table">')[2]
    # print(index2.partition('<div class="m-page J-ajax-page">')[0])
